const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: false, //代码运行时打开浏览器方便观察
    args: ['--no-sandbox'],
    dumpio: false
  })
  const page = await browser.newPage()

  const navigationPromise = page.waitForNavigation()

  await page.goto('https://teamwork.avicnet.cn/pro/user-login.html', {
    timedout: 10 * 1000,
    waitUntil: 'networkidle2'
  })

  await page.setViewport({
    width: 1536,
    height: 722
  })

  await navigationPromise

  await page.waitForSelector('#account')
  await page.waitForSelector('input[name="password"]')
  //输入账号密码
  await page.type('#account', "maoyunpeng")
  await page.type('input[name="password"]', "MYP897571")
  await page.waitForSelector('.table #submit')
  await page.click('.table #submit')

  await navigationPromise

  // await browser.close()
})()